package com.hbk.gen;

import java.util.ArrayList;
import java.util.List;

public class Field {

	private String type;
	private String name;
	private String column;
	private String fetch;
	private String comment;
	private List<Constant> constant = new ArrayList<>();
	private String form;
	private List<FieldColumn> columns = new ArrayList<>();

	public Field() {

	}

	public Field(String type, String name, String column, String fetch, String comment, List<Constant> constant) {
		super();
		this.type = type;
		this.name = name;
		this.column = column;
		this.fetch = fetch;
		this.comment = comment;
		this.constant = constant;
	}

	public String getType() {
		return type;
	}

	public String getDataType() {
		if (type.equals("Long")) {
			return "BIGINT";
		} else if (type.equals("String")) {
			return "VARCHAR(255)";
		} else if (type.equals("BigDecimal")) {
			return "DECIMAL(10,2)";
		} else if (type.equals("Date") && name.contains("time")) {
			return "DATETIME";
		} else if (type.equals("Date")) {
			return "DATE";
		} else if (type.equals("Boolean")) {
			return "TINYINT";
		} else if (type.equals("Integer")) {
			return "INT";
		} else {
			return "VARCHAR(255)";
		}
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getColumn() {
		return column;
	}

	public void setColumn(String column) {
		this.column = column;
	}

	public String getFetch() {
		return fetch;
	}

	public void setFetch(String fetch) {
		this.fetch = fetch;
	}

	public String getComment() {
		return comment == null ? name : comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}

	public List<Constant> getConstant() {
		return constant;
	}

	public void setConstant(List<Constant> constant) {
		this.constant = constant;
	}

	public String getForm() {
		return form;
	}

	public void setForm(String form) {
		this.form = form;
	}

	public List<FieldColumn> getColumns() {
		return columns;
	}

	public void setColumns(List<FieldColumn> columns) {
		this.columns = columns;
	}

}
